{include file="public/header" /}
<link rel="stylesheet" type="text/css" href="/static/admin/webupload/webuploader.css">
<link rel="stylesheet" type="text/css" href="/static/admin/webupload/style.css">
<style>
.file-item{float: left; position: relative; width: 110px;height: 110px; margin: 0 20px 20px 0; padding: 4px;}
.file-item .info{overflow: hidden;}
.uploader-list{width: 100%; overflow: hidden;}
</style>
<body class="gray-bg">
<div class="wrapper wrapper-content animated fadeInRight">
    <div class="row">
        <div class="col-sm-12">
            <div class="ibox float-e-margins">
                <div class="ibox-title">
                    <h5>添加到我的商品</h5>
                </div>
                <div class="ibox-content">
                    <form class="form-horizontal" name="edit" id="signupForm" method="post">
                        <input type="hidden" name="goodsId" value="{$yxGoods.goodsId}">
                        <div class="form-group">
                            <label class="col-sm-3 control-label">商品图片：</label>
                            <div class="input-group col-sm-4">
                                <!--dom结构部分-->
                                <div id="uploader-demo">
                                    <!--用来存放item-->
                                    <div class="file-item thumbnail" id="imgDiv">
                                        <img id="img" src="{$yxGoods.goodsImg}" width="100px">
                                    </div>
                                </div>
                            </div>
                        </div>
                        <div class="form-group">
                            <label class="col-sm-3 control-label">商品名称：</label>
                            <div class="input-group col-sm-5">
                                <input type="text" name="goodsName" class="form-control" value="{$yxGoods.goodsName}" readonly>
                            </div>
                        </div>
                        <div class="form-group">
                            <label class="col-sm-3 control-label">商品喜欢量：</label>
                            <div class="input-group col-sm-5">
                                <input type="text" class="form-control" value="{$yxGoods.favoriteNum}" readonly>
                            </div>
                        </div>
                        <div class="form-group">
                            <label class="col-sm-3 control-label">是否可以拼团：</label>
                            <div class="input-group col-sm-5">
                                {if $yxGoods.isPintuan == config('enum.isPintuan.yes.value')}
                                    <input type="text" class="form-control" value="可以" readonly>
                                {else /}
                                    <input type="text" class="form-control" value="不可以" readonly>
                                {/if}
                            </div>
                        </div>
                        <div class="form-group">
                            <label class="col-sm-3 control-label">商品拼团价：</label>
                            <div class="input-group col-sm-5">
                                <input type="text" class="form-control" value="{$yxGoods.tuanPrice}" readonly>
                            </div>
                        </div>
                        <div class="form-group">
                            <label class="col-sm-3 control-label">商品原价：</label>
                            <div class="input-group col-sm-5">
                                <input type="text" class="form-control" value="{$yxGoods.marketPrice}" readonly>
                            </div>
                        </div>
                        <div class="form-group">
                            <label class="col-sm-3 control-label">商品实际售价：</label>
                            <div class="input-group col-sm-5">
                                <input type="text" class="form-control" value="{$yxGoods.marketPrice}" readonly>
                            </div>
                        </div>
                        <div class="form-group">
                            <label class="col-sm-3 control-label">上架状态：</label>
                            <div class="input-group col-sm-5">
                                {if $yxGoods.isSale == config('enum.isSale.valid.value')}
                                    <input type="text" class="form-control" value="已上架" readonly>
                                {else /}
                                    <input type="text" class="form-control" value="已下架" readonly>
                                {/if}
                            </div>
                        </div>
                        <div class="form-group">
                            <label class="col-sm-3 control-label">商品描述：</label>
                            <div class="input-group col-sm-5">
                                <textarea class="form-control" readonly>{$yxGoods.littleDesc}</textarea>
                            </div>
                        </div>

                        <div class="form-group">
                            <label class="col-sm-3 control-label">兑换所需积分：</label>
                            <div class="input-group col-sm-5">
                                <input type="number" class="form-control" name="point">
                            </div>
                        </div>

                        <div class="hr-line-dashed"></div>
                        <div class="form-group">
                            <div class="col-sm-4 col-sm-offset-3">
                                <button id="formSubmit" type="submit" class="btn btn-primary"><i class="fa fa-check"></i> 提交</button>&nbsp;&nbsp;&nbsp;
                                <a class="btn btn-danger" href="{:url('index')}"><i class="fa fa-close"></i> 返回</a>
                            </div>
                        </div>
                    </form>
                </div>
            </div>

        </div>
    </div>
</div>
{include file="public/footer" /}
<script type="text/javascript" src="/static/admin/webupload/webuploader.min.js"></script>
<script type="text/javascript" src="/static/admin/js/common.js"></script>
<script type="text/javascript">

    //以下为官方示例
    $().ready(function () {

        // validate signup form on keyup and submit
        var icon = "<i class='fa fa-times-circle'></i> ";
        $("#signupForm").validate({
            rules: {
                point: {
                    required: true,
                    digits:true
                }
            },
            focusCleanup:true,
            submitHandler:function(form){

                $(form).ajaxSubmit({
                    type: 'post',
                    url: "{:url('addMyGoodsPost')}",
                    beforeSend:function() {
                        // 显示loading
                        index2 = layer.load(0, {
                            shade: [0.3,'#fff']
                        });
                        $("#formSubmit").attr('type', 'button')
                    },
                    success: function(data){

                        if (data['code'] != 1) {
                            layer.msg(data.msg,{icon:2,time:1000,shade: 0.1,}, function(index){
                                layer.close(index)
                            });
                            $("#formSubmit").attr('type', 'submit')
                            return false;
                        }

                        layer.msg(data.msg,{icon:1,time:1000,shade: 0.1,}, function(index){
                            window.location.href="{:url('index')}"
                        });
                    },
                    error: function(XmlHttpRequest, textStatus, errorThrown){
                        layer.msg('error!',{icon:1,time:1000});
                    },
                    complete:function() {
                        // 隐藏loading
                        layer.close(index2);
                    }
                });
            }
        });
    });

</script>
</body>
</html>